<template>
  <div class="recommend">
    <div class="title">
      <p class="title__bd">
        <slot name="title">{{ title }}</slot>
      </p>
      <router-link :to="url">
        <p class="title__ft">查看全部&nbsp;&nbsp;&gt;</p>
      </router-link>
    </div>
    <ul>
      <router-link
        tag="li"
        class="item border-bottom"
        v-for="(item, index) in recommendList"
        :key="index"
        to
        @click.native.prevent="
          $emit('link-to', { vid: item.vid, type: item.data_type })
        "
      >
        <img class="item-img" :src="item.imgUrl" />
        <div class="item-info">
          <p class="item-title">{{ item.title }}</p>
          <p class="item-desc">{{ item.desc }}</p>
          <div class="item-info__ft">
            <span class="item-info__num">
              {{ item.num }}
              <slot name="see">{{ numUnit }}</slot>
            </span>
            <span class="item-price" v-if="item.price_original">
              <span class="item-price__discounts">
                <span class="yen">&yen;</span>
                <strong>{{ item.price_discounts }}</strong>
              </span>
              <span class="item-price__original">
                <del>{{ item.price_original }}</del>
              </span>
            </span>
          </div>
        </div>
      </router-link>
    </ul>
  </div>
</template>
<script>
export default {
  name: "HomeItemOne",
  props: {
    list: {
      type: Array,
    },
    title: {
      type: String,
    },
    numUnit: {
      type: String,
    },
    url: {
      type: String | Object,
      default: "",
    },
  },
  data() {
    return {};
  },
  computed: {
    recommendList() {
      return this.list;
    },
  },
};
</script>
<style lang="less" scoped>
@import "~less/mixins.less";
.recommend {
  margin-top: 20px;
  position: relative;
  .home-border-bottom();
  .title {
    .title();
    .title__bd {
      font-weight: bold;
      font-size: 17px;
    }
  }
  .item {
    overflow: hidden;
    display: flex;
    height: 100px;
    margin-top: 10px;
    &-img {
      width: 130px;
      height: 85px;
      object-fit: cover;
      border-radius: 5px;
      background-color: #ccc;
    }
    &-title {
      margin-bottom: 8px;
      line-height: 16px;
      font-size: 14px;
      color: #333;
      font-weight: 600;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    &-desc {
      margin-bottom: 20px;
      font-size: 11px;
      line-height: 14px;
      color: #acacac;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    &-info {
      flex: 1;
      box-sizing: border-box;
      padding: 0 2px;
      margin-left: 10px;
      min-width: 0;
      &__num {
        font-size: 11px;
        line-height: 16px;
        color: #acacac;
      }
    }
    &-info__ft {
      display: flex;
      justify-content: space-between;
    }
    &-price {
      line-height: 16px;
      color: #acacac;
      .yen {
        font-size: 10px;
      }
      &__discounts {
        margin: 0 5px;
        font-size: 14px;
        color: #dc376d;
        font-weight: 600;
      }
      &__original {
        font-size: 10px;
      }
    }
  }
}
</style>
